
#%%

# 用于python性能测试的例子，每隔2秒创建10000个对象，对象里面有10个属性
import threading
import time


class MyObject:
    def __init__(self):
        self.a = 1
        self.b = 2
        self.c = 3
        self.d = 4
        self.e = 5
        self.f = 6
        self.g = 7
        self.h = 8
        self.i = 9
        self.j = 10


def create_objects():
    for i in range(1000000):
        obj = MyObject()
    time.sleep(0.1)


if __name__ == '__main__':
    start_time = time.time()
    threads = []
    for i in range(10):
        t = threading.Thread(target=create_objects)
        threads.append(t)
        t.start()
    for t in threads:
        t.join()
    end_time = time.time()
    print("Total time: ", end_time - start_time)
# %%
